// models/Chat.js
const mongoose = require('mongoose');

let ChatSchema = new mongoose.Schema({
  senderId: { type: mongoose.Schema.Types.ObjectId, ref: 'user', required: true },
  receiverId: { type: mongoose.Schema.Types.ObjectId, ref: 'user', required: true },
  content: { type: String, required: true },
  timestamp: { type: Date, default: Date.now },
  isRead: { type: Boolean, default: false }, //表示消息是否已读
  roomName: { type: mongoose.Schema.Types.ObjectId, ref: 'Friendship', required: true }
});

module.exports = mongoose.model('Chat', ChatSchema);
